/**
 * 
 */
package hu.gbalage.owl.editor.internal;

import java.io.InputStream;
import java.io.Reader;
import java.net.URI;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.semanticweb.owl.io.OWLOntologyInputSource;

/**
 * @author balage
 *
 */
public class IFileOWLInputSource implements OWLOntologyInputSource {

	final IFile file;
	
	public IFileOWLInputSource(IFile file){
		this.file = file;
	}
	
	/* (non-Javadoc)
	 * @see org.semanticweb.owl.io.OWLOntologyInputSource#getInputStream()
	 */
	public InputStream getInputStream() {
		try {
			return file.getContents();
		} catch (CoreException e) {
			e.printStackTrace();
			return null;
		}
	}

	/* (non-Javadoc)
	 * @see org.semanticweb.owl.io.OWLOntologyInputSource#getPhysicalURI()
	 */
	public URI getPhysicalURI() {
		return file.getLocationURI();
	}

	/* (non-Javadoc)
	 * @see org.semanticweb.owl.io.OWLOntologyInputSource#getReader()
	 */
	public Reader getReader() {
		return null;
	}

	/* (non-Javadoc)
	 * @see org.semanticweb.owl.io.OWLOntologyInputSource#isInputStreamAvailable()
	 */
	public boolean isInputStreamAvailable() {
		return true;
	}

	/* (non-Javadoc)
	 * @see org.semanticweb.owl.io.OWLOntologyInputSource#isReaderAvailable()
	 */
	public boolean isReaderAvailable() {
		return false;
	}

}
